package com.demo;

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.Socket;

/**
 * socket д
 * @author thduan
 * 2015-9-17 10:52:11
 */
public class SocketWriteRunnable implements Runnable {
	private Socket socket;
	private String sendMsg;
	
	public SocketWriteRunnable(Socket ss, String msg) {
		socket = ss;
		this.sendMsg = msg;
	}

	@Override
	public void run() {
		PrintWriter writer;
		try {
			writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())));
			writer.println(sendMsg);
			writer.flush();
			
			writer.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
